import java.awt.*;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class GameMessage {
    public static final int CMD_USERINFO=1;
    public static final int CMD_SETID=2;
    public static final int CMD_JOIN=3;
    public static final int CMD_FULL=4;
    public static final int CMD_READY=5;
    public static final int CMD_DEALCARDS=6;
    public static final int CMD_SETLANDLORD=7;
    public static final int CMD_PLAY=8;
    public static final int CMD_WIN=9;
    public static final int CMD_AUCTION=10;
    public static final int CMD_ILLEGAL=11;
    public static final int CMD_TABLEINFO=12;
    public static final int CMD_PASS=13;
    private int cmd;
    private HashMap infoMap;
    private int[] cards;

    public int getCmd() {
        return cmd;
    }

    public void setCmd(int cmd) {
        this.cmd = cmd;
    }

    public int[] getCards() {
        return cards;
    }

    public void setCards(int[] cards) {
        this.cards = cards;
    }

    public GameMessage() {
        cmd = CMD_ILLEGAL;
        infoMap = new HashMap();
        cards = null;
    }
    public void addInfo(String key,String value){
        infoMap.put(key,value);
    }
    public void addInfo(String key,int value){
        infoMap.put(key,String.valueOf(value));
    }
    public String toString(){
        String cmdStr="";
        cmdStr="cmd="+cmd;
        for (Object key:infoMap.keySet()
             ) {
            cmdStr = cmdStr + "&" + (String)key + "="+(String)infoMap.get(key);
        }
        if(cards!=null){
            cmdStr=cmdStr+"&cards=";
            for (int card:cards
                 ) {
                cmdStr = cmdStr+card+",";
            }
        }
        return cmdStr;
    }
}
